package com.fruit.system.service.impl;

import java.util.List;










import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.fruit.dao.BaseDao;
import com.fruit.service.impl.BaseServiceImpl;
import com.fruit.system.model.Log;
import com.fruit.system.service.LogService;
import com.fruit.util.LogUtil;

@Service("logService")
public class LogServiceImpl extends BaseServiceImpl<Log> implements LogService
{

	@Resource(name="logDao")
	private BaseDao<Log> logDao;
	//动态保存
	@Override
	public void saveLog(Log t)
	{
		String sql="insert into "+LogUtil.generateLogTableName(0)
				+"(operator,operName,operTime,operParams,operResult,resultMsg) values (?,?,?,?,?,?)";
		this.logDao.executeUpdateSql(sql, t.getOperator(),t.getOperName(),t.getOperTime(),t.getOperParams(),t.getOperResult(),t.getResultMsg());
		
	}
	
	//根据当前月份动态查找
	@Override
	public List<Log> findAllLogs()
	{
		String sql="select id,operator,operName,operTime,operParams,operResult,resultMsg from "+LogUtil.generateLogTableName(0);
		List<Log> logs= this.logDao.executeFindSql(sql);
		return logs;
	}

	@Override
	public BaseDao<Log> getEntityDao()
	{
		return logDao;
	}
}
